package com.yitong.bmd.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.yitong.bmd.domain.PageReults;
import com.yitong.bmd.domain.WhiteInfo;
import com.yitong.bmd.services.BmdManagerService;

@RestController
@RequestMapping("/bmd")
public class BmdManagerController {
	
	private Logger logger = LoggerFactory.getLogger(getClass());

	@Autowired
	BmdManagerService bmdManagerService;

	@ResponseBody
	@RequestMapping(value="/getWhiteUserList")
	public String getWhiteUserList(HttpServletRequest request) {
		logger.info("user controller...");
		String qynbzh = request.getParameter("qynbzh")==null?"":request.getParameter("qynbzh");			//企业内部账户
		String ygmc = request.getParameter("ygmc")==null?"":request.getParameter("ygmc");				//员工名称
		String sfxh = request.getParameter("sfxh")==null?"":request.getParameter("sfxh");				//身份证号
		String monthsalary = request.getParameter("monthsalary")==null?"":request.getParameter("monthsalary");//月薪范围
		String months = request.getParameter("months")==null?"":request.getParameter("months");			//已发工资月数
		String cxlb = request.getParameter("cxlb")==null?"":request.getParameter("cxlb");				//查询类别
		String curpageno = request.getParameter("curpageno");
		String pagesize = request.getParameter("pagesize");
		PageReults pageReults=bmdManagerService.getWhiteUserList(qynbzh,ygmc,sfxh,monthsalary,months,cxlb,Integer.parseInt(curpageno),Integer.parseInt(pagesize));
		return JSON.toJSONString(pageReults);
	}
	
	@ResponseBody
	@RequestMapping(value="/getEntLvl")
	public String getEntLvl(HttpServletRequest request) {
		logger.info("user controller...");
		String ent_cust_id = request.getParameter("ent_cust_id");			//企业内部账户
		String entlvl=bmdManagerService.getEntLvl(ent_cust_id);
		return JSON.toJSONString(entlvl);
	}
	
	@ResponseBody
	@RequestMapping(value="/insertWhiteList",method = RequestMethod.POST)
	public String insertWhitelist(@RequestBody List<WhiteInfo> list) {
		logger.info("user controller...");
		return bmdManagerService.insertWhitelist(list);
	}
	
	
	@ResponseBody
	@RequestMapping(value="/deleteWhiteList",method = RequestMethod.POST)
	public String deleteWhitelist(@RequestBody List<WhiteInfo> list) {
		logger.info("user controller...");
		return bmdManagerService.deleteWhitelist(list);
	}
	
}